          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                   B E N C H M A R K   (C) ST-Open 2012
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  THE CONTENT OF THIS FILE IS SUBJECT TO THE TERMS OF THE FT4FP-LICENSE!
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            You may copy and distribute this file as often as you want, but recipients are not
            allowed to pay anything for any copy of this file or its content. It isn't allowed
            to abuse its copyrighted content or introduced techniques for commercial purposes.
            Whatever is derived from this file or its content must be freely available without
            charge.

            You are free to modify the content of this file if you want to. However, derivates
            of the content of this file or parts of it *still* are subject to the terms of the
            FT4FP license. Recipients neither are allowed to pay anything for the original nor
            for altered or derived replica.
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       FREE THOUGHT FOR FREE PEOPLE: KEEP CASH AWAY FROM KNOWLEDGE!
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .include "..\\..\\..\\include\\yasm.h"
          .include "stb.h"
          .section .rdata, "dr"
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            jump table
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4, 0x00,15
      jt0:.quad    L10                                   # 1010   exit
          .quad    L11                                   # 1011   settings
          .quad    L12                                   # 1012   run tests
          .quad    L13                                   # 1013   comparison
          .quad    L14                                   # 1014   help OLH
          .quad    L15                                   # 1015        STbench
          .quad    L16                                   # 1016   about
          .quad    L17                                   # 1017   post tasks
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            strings
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
     LC00:.ascii   "STmenu"
          .byte    0x00, 0x00
     LC01:.ascii   "STopen"
          .byte    0x00, 0x00
     LC02:.ascii   "STbench"
          .byte    0x00
     LC03:.ascii   "STsetg"
          .byte    0x00, 0x00
     LC04:.ascii   "STabox"
          .byte    0x00, 0x00
     LC05:.ascii   "EDIT"
          .byte    0x00, 0x00, 0x00, 0x00
     LC06:.ascii   "gathering info..."
          .byte    0x00, 0x00, 0x00
          .p2align 4, 0x00,15
     LC07:.ascii   "..\\results\\...."
          .byte    0x00
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .text
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                            W i n M a i n ( )
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            -> RCX   Hinstance
               RDX   Hprevinstance (always zero)
               R08   EA command line parameters
               R09   window state flags (see Rxx labels)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            <- RAX   undefined
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
          .globl   _WinMain
          .def     _WinMain; .scl 2; .type 32; .endef
 _WinMain:subq     $0xF8,       %rsp
          movq     %rbp,        0xD8(%rsp)
          movq     %rsi,        0xE0(%rsp)
          movq     %rdi,        0xE8(%rsp)
          movq     %rbx,        0xF0(%rsp)
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            switch on 3D look
            ~~~~~~~~~~~~~~~~~~~~~~
          */
          movq     %rcx,        %rbp                     # RSI = Hinstance
          movl     %r9d,        %ebx                     # RBX = window state
          leaq     0x20(%rsp),  %rcx                     # RCX = EA commcntl-sex
          call     *__imp__InitCommonControlsEx(%rip)
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            retrieve parameters
            ~~~~~~~~~~~~~~~~~~~~~~
          */
          movl     $0x1005,     %edx                     # RDX = ID icon
          call     _LdIcon
          movq     %rax,        %rsi                     # RBP = Hicon
          xorl     %ecx,        %ecx                     # RCX = NULLHANDLE
          movl     $0x7F00,     %edx                     # RDX = IDC_ARROW
          call     _LdCursor
          movq     %rax,        %rdi                     # RDI = Hcursor
          call     _GtStkObj
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            register class
            ~~~~~~~~~~~~~~~~~~~~~~
          */
          pxor     %xmm0,       %xmm0                    # XM0 = 0
          leaq     _stb(%rip),  %r9                      # R09 = EA window procedure
          leaq     LC01(%rip),  %r8                      # R08 = EA class name
          leaq     LC00(%rip),  %rdx                     # RDX = EA menu name
          leaq     0x60(%rsp),  %rcx                     # RCX = EA WC
          movq     %xmm0,       0x60(%rsp)               # 0x00[WC] = 0
          movq     %r9,         0x68(%rsp)               # 0x08[WC] = EA window procedure
          movq     %xmm0,       0x70(%rsp)               # 0x10[WC] = 0, 0x14[WC] = 0
          movq     %rbp,        0x78(%rsp)               # 0x18[WC] = Hinstance
          movq     %rsi,        0x80(%rsp)               # 0x20[WC] = Hicon
          movq     %rdi,        0x88(%rsp)               # 0x28[WC] = Hcursor
          movq     %rax,        0x90(%rsp)               # 0x30[WC] = background colour
          movq     %rdx,        0x98(%rsp)               # 0x38[WC] = EA menu name
          movq     %r8,         0xA0(%rsp)               # 0x40[WC] = EA class name
          call     _RegClass
          testl    %eax,        %eax                     # registered?
          je       2f
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            start ST Loader
            ~~~~~~~~~~~~~~~~~~~~~~
          */
          movq     $0x01,       _OLH_MODE(%rip)          # OLH edit  disabled
          call     _LDinit
          movq     _BNR(%rip),  %rsi                     # RSI = BNR
          testl    %eax,        %eax
          jne      2f
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            RIS and create window
            ~~~~~~~~~~~~~~~~~~~~~~
          */
          cvtdq2ps  SCN_W0(%rsi), %xmm0                   # XM0 = WHWH
          cvtdq2ps  RIS_CX(%rsi), %xmm2                   # XM2 = xywh (percent)
          cvtdq2ps  WRATIO(%rsi), %xmm1                   # XM1 = 4 * 10000
          pxor      %xmm3,        %xmm3                   # XM3 = 0
          mulps     %xmm2,        %xmm0                   # xywh * WHWH
          divps     %xmm1,        %xmm0                   # all / 10000
          cvttps2dq %xmm0,        %xmm1                   # convert
          movdqa    %xmm1,        0x20(%rsp)              # store pixel
          xorl      %ecx,         %ecx                    # RCX = 0
          leaq      LC01(%rip),   %rdx                    # RDX = EA class name
          leaq      LC02(%rip),   %r8                     # R08 = EA title
          movl      0x24(%rsp),   %eax                    # RDI = y
          movl      0x28(%rsp),   %edi                    # RDI = w
          movl      0x2C(%rsp),   %r9d                    # R09 = h
          movl      %ecx,         0x24(%rsp)              # clear upper DD of x
          movq      %rax,         0x28(%rsp)              # y
          movq      %rdi,         0x30(%rsp)              # w
          movq      %r9,          0x38(%rsp)              # h
          movdqa    %xmm3,        0x40(%rsp)              # HWND = 0, HMENU = 0
          movq      %rbp,         0x50(%rsp)              # Hinstance
          movq      %rcx,         0x58(%rsp)              # create parameters
          movq      $0x00CF0000,  %r9                     # R09 = style
          call      _WnCreatX
          testq     %rax,         %rax                    # error?
          je        2f
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            store params and show
            ~~~~~~~~~~~~~~~~~~~~~~
          */
          movq     %rbp,        HI_PGM(%rsi)             # store HI_PGM
          movq     %rax,        HW_PGM(%rsi)             # store HW_PGM
          movq     %rax,        %rcx                     # RCX = HWND
          movl     %ebx,        %edx                     # RDX = window state
          call     _MNUtxt
          call     _WinSh
          call     _WnUpd
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            add accelerator
            ~~~~~~~~~~~~~~~~~~~~~~
          */
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            message loop
            ~~~~~~~~~~~~~~~~~~~~~~
          */
         leaq     0x80(%rsp),   %rcx                     # RCX = EA MSG
          xorl     %edx,        %edx                     # all windows
          xorq     %r8,         %r8                      # NULL
          xorq     %r9,         %r9                      # NULL
        0:call     _GetMsg
          testl    %eax,        %eax                     # WM_QUIT?
          je       1f
          incl     %eax                                  # shorter than cmp $0xFFFFFFFF,%eax
          je       0b
          call     _TrnsMsg
          call     _DispMsg
          jmp      0b
          /*
            ~~~~~~~~~~~~~~~~~~~~~~
            exit
            ~~~~~~~~~~~~~~~~~~~~~~
          */
        1:call     _LDexit
          incl     %eax                                  # RC = 1
        2:movq     0xD8(%rsp),  %rbp
          movq     0xE0(%rsp),  %rsi
          movq     0xE8(%rsp),  %rdi
          movq     0xF0(%rsp),  %rbx
          addq     $0xF8,       %rsp
          ret
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                             S T B ( e n c h )
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            -> RCX   HWND
               RDX   MSG
               R08   WPARAM
               R09   LPARAM
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            <- RAX   0000 0000   processed
                     ???? ????   not processed
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
          .globl   _stb
          .def     _stb; .scl 2; .type 32; .endef
     _stb:subq     $0xF8,       %rsp
          movq     _BNR(%rip),  %rax                     # RAX = BNR
          pxor     %xmm0,       %xmm0                    # XM0 = 0
          movq     %rsi,        0xC0(%rsp)
          movq     %rdi,        0xC8(%rsp)
          movq     %rbx,        0xD0(%rsp)
          movq     %r9,         0xD8(%rsp)
          movq     %r8,         0xE0(%rsp)
          movq     %rdx,        0xE8(%rsp)
          movq     %rcx,        0xF0(%rsp)
          movq     %rax,        %rsi                     # RSI = BNR
          andq     $0x0000FFFF, %r8                      # R08 = ID
          movq     HI_PGM(%rax),%rbx                     # RBX = H_INST
          movq     HW_EDT(%rax),%rdi                     # RDI = H_EDIT
          cmpl     $0x0007,     %edx                     # WM_SETFOCUS?
          je       L02
          cmpl     $0x0005,     %edx                     # WM_SIZE?
          je       L01
          cmpl     $0x0111,     %edx                     # WM_COMMAND?
          je       L03
          cmpl     $0x0002,     %edx                     # WM_QUIT?
          je       L00
          cmpl     $0x0001,     %edx                     # WM_CREATE?
          jne      DWP
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            WM_CREATE
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          movl     $0x1000,     %edx                     # RDX = ID_EDIT
          xorq     %r8,         %r8                      # R08 = 0
          movq     $0x50200044, %r9                      # R09 = flags
          movdqa   %xmm0,       0x20(%rsp)               # x,  y
          movdqa   %xmm0,       0x30(%rsp)               # cx, cy
          movq     %rcx,        0x40(%rsp)               # HWND parent
          movq     %rdx,        0x48(%rsp)               # ID
          movq     %rbx,        0x50(%rsp)               # hinst
          movq     %xmm0,       0x58(%rsp)               # 0
          movq     %rcx,        %rbx                     # RBX = HWND
          leaq     LC05(%rip),  %rdx                     # RDX = class
          xorl     %ecx,        %ecx                     # RCX = 0
          call     _WnCreatX
          movq     %rax,        HW_EDT(%rsi)             # store HWND edit
          movq     %rax,        %rdi                     # RDI = H_EDIT
          testq    %rax,        %rax                     # error?
          je       L10
          movl     $0x0A,       %ecx                     # RCX = OEM_FIXED_FONT
          call     _GtStkObj
          movq     %rdi,        %rcx                     # RCX = HWND edit
          movl     $0x30,       %edx                     # RDX = WM_SETFONT
          movq     %rax,        %r8                      # R08 = handle
          movq     $0x01,       %r9                      # R09 = redraw
          call     _PostM
          movq     $0x4000,     %rcx                     # allocate buffer
          call     _AloMem
          movq     %rax,        EA_MLE(%rsi)             # store buffer address
          testq    %rax,        %rax                     # address?
          je       L00
          movq     %rdi,        %rcx                     # RCX = HWND
          movl     $0x0C,       %edx                     # RDX = WM_SETTEXT
          xorq     %r8,         %r8                      # R08 = 0
          leaq     LC06(%rip),  %r9                      # R09 = EA text
          call     _SendM
          movq     %rbx,        %rcx                     # RCX = HWND
          movl     $0x0111,     %edx                     # RDX = WM_COMMAND
          movq     $0x1017,     %r8                      # R08 = (WPARAM) = ID
          xorq     %r9,         %r9                      # R09 = (LPARAM) = 0
          call     _PostM
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            WM_QUIT
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L00:movq     EA_MLE(%rsi),%rcx                     # RCX = EA_MLE
          call     _FreMem
          xorl     %ecx,        %ecx
          call     _Pquit
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            WM_SIZE
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L01:testq     %r8,         %r8                     # SIZE_RESTORED?
          jne       XIT
          movl      %r9d,        %eax                    # RAX = hhhh wwww
          movq      %rdi,        %rcx                    # RCX = HWND edit
          xorl      %edx,        %edx                    # RDX = 0
          shrl      $0x10,       %eax                    # RAX = 0000 hhhh
          xorq      %r8,         %r8                     # R08 = 0
          andq      $0xFFFF,     %r9                     # R09 = 0000 wwww
          movq      %rax,        0x20(%rsp)              # s20 = h
          movq      $0x01,       0x28(%rsp)              # s28 = TRUE
          call      _WnMov
          movq      HW_PGM(%rsi),%rcx
          leaq      0x24(%rsp),  %rdx                    # RDX = EA WINDOWPLACEMENT
          call      _GtPos
          movl      0x40(%rsp),  %edx                    # RDX = x
          movl      0x44(%rsp),  %r8d                    # R08 = y
          movl      0x48(%rsp),  %r9d                    # R09 = right
          movl      0x4C(%rsp),  %eax                    # RAX = bottom
          subl      %edx,        0x48(%rsp)              # w...
          subl      %r8d,        0x4C(%rsp)              # h...
          subl      %edx,        %r9d                    # R09 = w
          subl      %r8d,        %eax                    # RAX = h
          cvtdq2ps  SCN_W0(%rsi),%xmm0                   # XM0 = WHWH
          cvtdq2ps  0x40(%rsp),  %xmm2                   # XM2 = xywh (pixel)
          cvtdq2ps  WRATIO(%rsi),%xmm1                   # XM1 = 4 * 10000
          divps     %xmm0,       %xmm2                   # xywh / WHWH
          mulps     %xmm1,       %xmm2                   # all * 10000
          cvttps2dq %xmm2,       %xmm1                   # convert
          movdqa    %xmm1,       RIS_CX(%rsi)            # store xywh
          movq      %rax,        0x20(%rsp)              # P_5 = h
          movq      $0x01,       0x28(%rsp)              # P_6 = repaint
          call      _WnMov
          jmp       XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            WM_SETFOCUS
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L02:movq     %rdi,        %rcx                     # RCX = HWND edit
          call     _WnFoc
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            WM_COMMAND
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L03:subq     $0x1010,     %r8
          js       DWP
          cmpq     $0x07,       %r8
          ja       L18
          jmp      *jt0(, %r8, 8)
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            00 exit
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L10:call     _KillWin
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            01 settings
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L11:leaq     _setgs(%rip),%rcx                     # RCX = EA procedure
          leaq     LC03(%rip),  %rdx                     # RDX = EA ID
          call     _DBox
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            02 run
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L12:movq     %rdi,        %rcx                     # RCX = HW_EDT
          movq     EA_MLE(%rsi),%rdx                     # RDX = EA_MLE
          call     _bench
          call     _shres
          call     _emit
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            03 comparison
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L13:leaq     _compr(%rip),%rcx                     # RCX = EA procedure
          movl     $0x1140,     %edx                     # RDX = ID
          call     _DBox
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            04 help for help
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L14:xorl     %ecx,        %ecx                     # help OLH
          jmp      0f
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            05 help STbench
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L15:movl     $0x01,       %ecx                     # help STbench
        0:call     _Help
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            06 about box
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L16:leaq     _about(%rip),%rcx                     # RCX = EA procedure
          leaq     LC04(%rip),  %rdx                     # RDX = EA ID
          call     _DBox
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            07 post tasks
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L17:leaq     0x20(%rsp),  %rcx
          movl     RES_NR(%rsi),%r9d                     # R09 = next block
          movl     $0x01,       0x30(%rsp)               # field 00000001
          movl     $0x23,       0x34(%rsp)               # r, w, static
          call     _LDreq
          movq     0x20(%rsp),  %rbx                     # RBX = field EA
          movq     0x38(%rsp),  %r8                      # R08 =       MH
          movq     %rdi,        %rcx                     # RCX = HW_EDT
          movq     EA_MLE(%rsi),%rdx                     # RDX = EA_MLE
          testl    %eax,        %eax                     # load failed?
          jne      L10
          imull    $0x1400,     %r9d                     # R09 = offset block
          addq     $0x0100,     %rbx                     # RBX = EA data area
          orb      $0x04,       0x08(%r8)                # set LDR_CHANGED
          addq     %rbx,        %r9                      # R09 = EA block
          movq     %r8,         MH_RES(%rsi)
          movq     %rbx,        EA_RES(%rsi)
          movq     %r9,         RUN_00(%rsi)             # initial RUN_00
          call     _pinfo
          call     _shres
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~
            08 language
            ~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      L18:subq     $0x08,       %r8                      # R08 = language
          cmpq     $0x0F,       %r8                      # valid?
          ja       XIZ
          movl     %r8d,        USRLNG(%rsi)             # set
          call     _MNUtxt
          jmp      XIZ
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                        W R I T E    R E S U L T S
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            -> RCX = BNR
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            <- RAX   00000000   processed
                     ????????   not processed
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
          .globl   _emit
          .def     _emit; .scl 2; .type 32; .endef
    _emit:subq     $0xF8,       %rsp
          pxor     %xmm0,       %xmm0
          movdqa   LC07(%rip),  %xmm1                    # XM1 = filename template
          movl     RES_NR(%rsi),%eax
          movdqa   %xmm0,       0x20(%rsp)               # clear FH
          movdqa   %xmm0,       0x30(%rsp)
          movdqa   %xmm0,       0x40(%rsp)
          movdqa   %xmm1,       0x50(%rsp)               # store template
          movq     %rsi,        0xC0(%rsp)
          movq     %rdi,        0xC8(%rsp)
          movq     %rbx,        0xD0(%rsp)
          movq     %r9,         0xD8(%rsp)
          movq     %r8,         0xE0(%rsp)
          movq     %rdx,        0xE8(%rsp)
          movq     %rcx,        0xF0(%rsp)
          movl     %eax,        %ecx                     # RCX = next number
          movq     RUN_00(%rsi),%rbx                     # RBX = EA result block
          leaq     0x5B(%rsp),  %rdx                     # RDX = insertion point
          decl     %ecx                                  # RCX = current number
          call     _W2hex
          leaq     0x20(%rsp),  %rcx                     # RCX = FH
          xorl     %edx,        %edx                     # RDX = 0 (initial size)
          xorq     %r8,         %r8                      # R08 = 0 (open or create)
          leaq     0x50(%rsp),  %r9                      # R09 = EA filename
          call     _Fopen
          testl    %eax,        %eax                     # failed?
          jne      XIT
          movl     $0x1400,     0x08(%rcx)               # FH.Fsize
          movq     %rbx,        0x10(%rcx)               # FH.Mbase
          call     _Fwrite
          testl    %eax,        %eax
          jne      XIT
          call     _Fclose
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            common exit
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      XIZ:xorl     %eax,        %eax
      XIT:movq     0xC0(%rsp),  %rsi
          movq     0xC8(%rsp),  %rdi
          movq     0xD0(%rsp),  %rbx
          movq     0xD8(%rsp),  %r9
          movq     0xE0(%rsp),  %r8
          movq     0xE8(%rsp),  %rdx
          movq     0xF0(%rsp),  %rcx
          addq     $0xF8,       %rsp
          ret
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            default window procedure
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .p2align 4,,15
      DWP:movq     0xC0(%rsp),  %rsi
          movq     0xC8(%rsp),  %rdi
          movq     0xD0(%rsp),  %rbx
          movq     0xD8(%rsp),  %r9
          movq     0xE0(%rsp),  %r8
          movq     0xE8(%rsp),  %rdx
          movq     0xF0(%rsp),  %rcx
          addq     $0xF8,       %rsp
          jmp      _DefWP
          /*
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            variables
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          */
          .comm    _BMM,        8, 3
          .comm    _BBF,        8, 3
          .comm    _OBF,        8, 3
          .comm    _TST,        8, 3
          .comm    _BNR,        8, 3
          .comm    _DVAR,       8, 3
          .comm    _QVAR,       8, 3
          .comm    _BST,        8, 3
          .comm    _MHSTR,      8, 3
          .comm    _LDR_AVAIL,  8, 3
